package com.novel.base.exception;

import com.novel.base.constants.CustomExceptionEnum;
import lombok.Getter;

/**
 * CustomException
 *
 * @author 樊温军
 * @date 2025/3/22 上午11:22
 */
@Getter
public class CustomException extends RuntimeException {
    private int statusCode;
    private String errorCode;
    private String errorMessage;

    public CustomException(String errorMessage) {
        super(errorMessage);
        this.statusCode = 1;
        this.errorCode = "Custom Exception";
        this.errorMessage = errorMessage;
    }

    public CustomException(CustomExceptionEnum customExceptionEnum) {
        super(customExceptionEnum.getErrorMessage());
        this.statusCode = customExceptionEnum.getStatusCode();
        this.errorCode = customExceptionEnum.getErrorCode();
        this.errorMessage = customExceptionEnum.getErrorMessage();
    }

    public CustomException(String errorMessage, int statusCode, String errorCode) {
        super(errorMessage);
        this.statusCode = statusCode;
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public CustomException(Exception e) {
        super(e.getMessage());
    }

}